package priv.lirenhe.exam02.B;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class Example01 {

	public static void main(String[] args) {
		System.out.println(getUsedTimeH());
		System.out.println(getUsedTimeLH());
	}
	
	public static String getUsedTimeH(){
		Map<String,String> hashMap = new HashMap<String,String>();
		
		long startTime = System.currentTimeMillis();
		for(int i=0; i<50000; i++){
			hashMap.put(i+"","0123456789");
		}
		long endTime = System.currentTimeMillis();
		
		long usedTimeL = endTime - startTime;
		float usedTimeF = 0.0F;
		if(usedTimeL > 1000){
			usedTimeF = usedTimeL / 1000;
			return usedTimeF + "秒";
		}
		
		return usedTimeL + "毫秒";
	}
	
	public static String getUsedTimeLH(){
		Map<String,String> linkedHashMap = new LinkedHashMap<String,String>();
		
		long startTime = System.currentTimeMillis();
		for(int i=0; i<50000; i++){
			linkedHashMap.put(i+"","0123456789");
		}
		long endTime = System.currentTimeMillis();
		
		long usedTimeL = endTime - startTime;
		float usedTimeF = 0.0F;
		if(usedTimeL > 1000){
			usedTimeF = usedTimeL / 1000;
			return usedTimeF + "秒";
		}
		
		return usedTimeL + "毫秒";
	}
}

